Base class for any graphical component. More...
Public Member Functions | |
Component () | |
virtual | ~Component () |
Layout * | getLayout () const |
Theme * | getTheme () const |
nkMaths::Point | getPositionInParent () const |
nkMaths::Point | getPositionInScreen () const |
int | getWidth () const |
int | getHeight () const |
nkMaths::Rectangle | getAreaInParent () const |
nkMaths::Rectangle | getAreaInScreen () const |
virtual nkMaths::Point | getBorderExtents () const |
virtual int | getLayoutAllowedWidth () const |
virtual int | getLayoutAllowedHeight () const |
virtual int | getLayoutAllowedOffsetX () const |
virtual int | getLayoutAllowedOffsetY () const |
bool | isInitialized () const |
Component * | getParentComponent () const |
COMPONENT_TYPE | getComponentType () const |
const char * | getComponentName () const |
bool | getVisibility () const |
virtual const char * | getLabel () const |
void * | getData () const |
bool | isEnabled () const |
bool | isForegroundWindow () const |
unsigned int | getZDepth () const |
bool | getVisibleOnLoad () const |
virtual Layout * | setLayout (LAYOUT_TYPE layoutType) |
virtual void | setTheme (Theme *theme) |
virtual void | setPositionInParent (nkMaths::Point position) |
virtual void | setPositionInScreen (nkMaths::Point position) |
virtual void | setSize (int width, int height) |
virtual void | setWidth (int width) |
virtual void | setHeight (int height) |
void | setMinSize (unsigned int width, unsigned int height) |
void | setMaxSize (unsigned int width, unsigned int height) |
void | setRatio (float widthOverHeight) |
virtual void | setAreaInParent (const nkMaths::Rectangle &area) |
virtual void | setAreaInScreen (const nkMaths::Rectangle &area) |
virtual void | setParentComponent (Component *parent, bool makeItVisible=true) |
virtual void | setLabel (const std::string_view &label) |
void | setComponentName (const std::string_view &name) |
virtual void | setVisibility (bool value) |
void | setData (void *data) |
void | setEnabled (bool value) |
void | setVisibleOnLoad (bool value) |
void | addChild (Component *child, bool makeItVisible=true) |
void | removeChild (Component *child) |
void | removeChild (unsigned int index) |
Component * | getChild (unsigned int index) |
unsigned int | getChildIndex (Component *child) |
void | unloadWithChildren () |
void | loadWithChildren () |
void | updateZDepth () |
void | bringToForeground () |
void | focusWindow () |
nkMaths::Point | getCoordRelativeFromAbsolute (const nkMaths::Point &absCoords) |
nkMaths::Point | getCoordAbsoluteFromRelative (const nkMaths::Point &relCoords) |
virtual void | load ()=0 |
virtual void | unload ()=0 |
virtual void | updateWindow () |
nkImages::Image | paintToImage (bool withFrame=false) |
void | simulateEvent (const InputDescriptor &inputDescription) |
void | onSized () |
virtual void | exportClassToTree (nkExport::Node *rootNode) override |
virtual void | exportIntrospection (nkExport::Node *rootNode) |
virtual void | importClassFromTree (nkExport::Node *rootNode) override |
![]() | |
Exportable () | |
virtual | ~Exportable () |
Base class for any graphical component.
nkWinUi::Component::Component | ( | ) |
Constructor.
|
virtual |
Destructor.
Layout* nkWinUi::Component::getLayout | ( | ) | const |
Theme* nkWinUi::Component::getTheme | ( | ) | const |
nkMaths::Point nkWinUi::Component::getPositionInParent | ( | ) | const |
nkMaths::Point nkWinUi::Component::getPositionInScreen | ( | ) | const |
int nkWinUi::Component::getWidth | ( | ) | const |
int nkWinUi::Component::getHeight | ( | ) | const |
nkMaths::Rectangle nkWinUi::Component::getAreaInParent | ( | ) | const |
nkMaths::Rectangle nkWinUi::Component::getAreaInScreen | ( | ) | const |
|
virtual |
|
virtual |
Reimplemented in nkWinUi::GroupBox.
|
virtual |
Reimplemented in nkWinUi::GroupBox.
|
virtual |
Reimplemented in nkWinUi::GroupBox.
|
virtual |
Reimplemented in nkWinUi::GroupBox.
bool nkWinUi::Component::isInitialized | ( | ) | const |
Component* nkWinUi::Component::getParentComponent | ( | ) | const |
COMPONENT_TYPE nkWinUi::Component::getComponentType | ( | ) | const |
const char* nkWinUi::Component::getComponentName | ( | ) | const |
bool nkWinUi::Component::getVisibility | ( | ) | const |
|
virtual |
void* nkWinUi::Component::getData | ( | ) | const |
bool nkWinUi::Component::isEnabled | ( | ) | const |
bool nkWinUi::Component::isForegroundWindow | ( | ) | const |
unsigned int nkWinUi::Component::getZDepth | ( | ) | const |
bool nkWinUi::Component::getVisibleOnLoad | ( | ) | const |
|
virtual |
Sets the component's layout type by instantiating a new layout, and returns it for populating.
layoutType | The type of layout the component should instantiate. |
Reimplemented in nkWinUi::TabWindow.
|
virtual |
Sets an overridden theme to use for the component. The global theme to use through the application can be set using ThemeManager::setActiveTheme. However, if a sub-set of components needs to use a specific theme, it can be overridden through this setter.
theme | The theme to use rather than the active one. |
|
virtual |
Change the component's position, relative to the parent.
position | The position to assign, in pixels. |
|
virtual |
Change the component's position, relative to screen (absolute).
position | The position to assign, in pixels. |
|
virtual |
Change the component's size.
width | The width to assign, in pixels. |
height | The height to assign, in pixels. |
|
virtual |
Change the component's width.
width | The width to assign, in pixels. |
|
virtual |
Change the component's height.
height | The height to assign, in pixels. |
void nkWinUi::Component::setMinSize | ( | unsigned int | width, |
unsigned int | height | ||
) |
Assign a minimum size the component should have.
width | The minimum width possible, in pixels. -1 symbolizes "no limit". |
height | The minimum height possible, in pixels. -1 symbolizes "no limit". |
void nkWinUi::Component::setMaxSize | ( | unsigned int | width, |
unsigned int | height | ||
) |
Assign a maximum size the component should have.
width | The maximum width possible, in pixels. -1 symbolizes "no limit". |
height | The maximum height possible, in pixels. -1 symbolizes "no limit". |
void nkWinUi::Component::setRatio | ( | float | widthOverHeight | ) |
Assign a ratio the component has to respect.
widthOverHeight | The ratio, as width / height. |
|
virtual |
Assign an area the component should cover, relative to its parent.
area | The area, in pixels, to cover. |
|
virtual |
Assign an area the component should cover, relative to the screen.
area | The area, in pixels, to cover. |
|
virtual |
Changes the parent component.
parent | The parent component to assign. |
makeItVisible | If the component should be made visible within the parent, if the parent is visible. |
|
virtual |
Changes the label of the component. This can be the title of a nkWinUi::Window, the txt of a nkWinUi::EditBox...
label | The text to assign. |
void nkWinUi::Component::setComponentName | ( | const std::string_view & | name | ) |
Sets the component name.
name | The name to assign. |
|
virtual |
Sets whether this component should be visible.
value | If the component should be visible on screen (true) or not (false). |
void nkWinUi::Component::setData | ( | void * | data | ) |
Attach user data to the component.
data | The user data to attach to the component. |
void nkWinUi::Component::setEnabled | ( | bool | value | ) |
Sets whether the component is enabled or not.
value | If it is enabled (true) or not (false). |
void nkWinUi::Component::setVisibleOnLoad | ( | bool | value | ) |
Sets whether a component should be visible after its load operation, or not. This can be used to load components but keep them hidden until further notice.
value | If the component should be visible (true) or not (false). |
void nkWinUi::Component::addChild | ( | Component * | child, |
bool | makeItVisible = true |
||
) |
Add a child component.
child | The component that should become a child. |
makeItVisible | If the child component has to become visible if the parent is also visible. |
void nkWinUi::Component::removeChild | ( | Component * | child | ) |
Removes a child.
child | The child component that should not be a child anymore. |
void nkWinUi::Component::removeChild | ( | unsigned int | index | ) |
Removes a child.
index | The index of the child component, in the children list, that should be removed. |
Component* nkWinUi::Component::getChild | ( | unsigned int | index | ) |
Returns a child component.
index | The child component at given index, in the children list. |
unsigned int nkWinUi::Component::getChildIndex | ( | Component * | child | ) |
Returns the index in the list of one child component.
child | The child component chich index is needed. |
void nkWinUi::Component::unloadWithChildren | ( | ) |
Unloads the component along with its children.
void nkWinUi::Component::loadWithChildren | ( | ) |
Loads the component along with its children.
void nkWinUi::Component::updateZDepth | ( | ) |
Updates the depth of the component. Computed from the component's hierarchy.
void nkWinUi::Component::bringToForeground | ( | ) |
Brings the component to the foreground.
void nkWinUi::Component::focusWindow | ( | ) |
Puts the component into focus.
nkMaths::Point nkWinUi::Component::getCoordRelativeFromAbsolute | ( | const nkMaths::Point & | absCoords | ) |
Converts given coordinates from absolute in screen to relative to the component.
absCoords | The absolute coordinates to convert. |
nkMaths::Point nkWinUi::Component::getCoordAbsoluteFromRelative | ( | const nkMaths::Point & | relCoords | ) |
Converts given coordinates from relative to the component to absolute in screen.
relCoords | The relative coordinates to convert. |
|
pure virtual |
Loads the component. This will trigger the initialization of the component in the windowing system.
|
pure virtual |
Unloads the component. This will make the component release resources from the windowing system.
|
virtual |
Update the window for changes that could have occurred.
nkImages::Image nkWinUi::Component::paintToImage | ( | bool | withFrame = false | ) |
withFrame | Whether the non-client area, aka frame, should also be included in the image. |
void nkWinUi::Component::simulateEvent | ( | const InputDescriptor & | inputDescription | ) |
Simulates an event within the component, fitting the description given. Using this, it is possible to automatically hover components, or automatically generate keyboard events. Note that simulating an event will not impact the system's input system (cursor or focus).
inputDescription | The description of the input to simulate. |
void nkWinUi::Component::onSized | ( | ) |
Component's callback for resize events.
|
overridevirtual |
A basic exporting capability.
rootNode | The root of the tree to export into. |
Implements nkExport::Exportable.
Reimplemented in nkWinUi::ContextMenu.
|
virtual |
A basic exporting capability, for components inheriting. Components inheriting this class should rather reimplement this function to export their internal data.
rootNode | The root of the tree to export into. |
Reimplemented in nkWinUi::TreeView, nkWinUi::TabWindow, nkWinUi::ListBox, nkWinUi::ComboBox, nkWinUi::FileExplorer, nkWinUi::GraphicsWindow, nkWinUi::Static, nkWinUi::Window, nkWinUi::EditBox, and nkWinUi::LogWin.
|
overridevirtual |
A basic importing capability.
rootNode | The root of the tree to import from. |
Implements nkExport::Exportable.
Reimplemented in nkWinUi::TreeView, nkWinUi::TabWindow, nkWinUi::ListBox, nkWinUi::ComboBox, nkWinUi::FileExplorer, nkWinUi::ContextMenu, nkWinUi::GraphicsWindow, nkWinUi::Static, nkWinUi::Window, nkWinUi::EditBox, and nkWinUi::LogWin.